function [xu,yu,xl,yl,xc,yc]=GenerateNACASeries6Airfoil(afid,dotcount,xmod)

%--------------------------------------------------------------------------
%GenerateNACASeries6Airfoil
%Version 1.10
%Created by Stepen (zerocross_raptor@yahoo.com)
%Created 2 December 2010
%Last modified 1 December 2011
%--------------------------------------------------------------------------
%GenerateNACASeries6Airfoil generates the airfoil vertexes' coordinate of
%the given NACA Series 6 Airfoil. The math equation used to generates the
%airfoil coordinates is based on Theory of Wing Section Chapter 6 by Abbott
%and Doenhoff.
%--------------------------------------------------------------------------
%Syntax:
%[xu,yu,xl,yl,xc,yc]=GenerateNACASeries6Airfoil(afid,dotcount,xmod)
%Input argument:
%- afid (1 x 1 str) specifies NACA Series 6 Airfoil identifier. (Note that
%  there exist several format of identifier for NACA Series 6 Airfoil. This
%  code only accept the basic format of NACA Series 6 identifer (6X-XXX or
%  6XAXXX).
%- dotcount (1 x 1 int) specifies the number of vertexes to be generated on
%  the airfoil's camber/mean line.
%- xmod (str) specifies the mode of airfoil vertex distribution. Enter
%  'Uniform' to create uniform vertex distribution or 'Cosine' to create
%  vertex distribution based on cosine function (More vertex on the leading
%  edge region).
%Output argument:
%- xu (i x 1 num) specifies the x axis location of airfoil's upper surface
%  vertexes in fraction of chord. The airfoil's upper surface vertex are
%  arranged from leading edge (the first element of xu) to the trailing
%  edge (the last element of xu).
%- yu (i x 1 num) specifies the y axis location of airfoil's upper surface
%  vertexes in fraction of chord. The airfoil's upper surface vertex are
%  arranged from leading edge (the first element of yu) to the trailing
%  edge (the last element of yu).
%- xl (i x 1 num) specifies the x axis location of airfoil's lower surface
%  vertexes in fraction of chord. The airfoil's lower surface vertex are
%  arranged from leading edge (the first element of xl) to the trailing
%  edge (the last element of xl).
%- yl (i x 1 num) specifies the y axis location of airfoil's lower surface
%  vertexes in fraction of chord. The airfoil's lower surface vertex are
%  arranged from leading edge (the first element of yl) to the trailing
%  edge (the last element of yl).
%- xc (i x 1 num) specifies the x axis location of airfoil's camber line
%  vertexes in fraction of chord. The airfoil's camber line vertex are
%  arranged from leading edge (the first element of xc) to the trailing
%  edge (the last element of xc).
%- yc (i x 1 num) specifies the y axis location of airfoil's camber line
%  vertexes in fraction of chord. The airfoil's camber line vertex are
%  arranged from leading edge (the first element of yc) to the trailing
%  edge (the last element of yc).
%--------------------------------------------------------------------------

%CodeStart-----------------------------------------------------------------
%Checking input afid
    if ~ischar(afid)
        error('Airfoil identifier must be a string!')
    end
    if (numel(afid)~=6)&&(numel(afid)~=7)
        error('Airfoil identifier must be in 6X-XXX or 6XAXXX format!')
    end
    if isempty(str2double(afid))
        error('Airfoil identifier must be a in 6X-XXX or 6XAXXX format!')
    end
    ida=str2double(afid([1,2]));
    if (ida~=63)&&(ida~=64)&&(ida~=65)&&(ida~=66)
        error('Airfoil identifier must start with 63, 64, 65, 66!')
    end
    if numel(afid)==6
        idb=afid(3);
        if (~strcmpi(idb,'-'))&&(~strcmpi(idb,'A'))
            error(['Airfoil identifier must be a in 6X-XXX or',...
                  ' 6XAXXX format!'])
        end
        if strcmpi(idb,'-')
            tmod=0;
        elseif strcmpi(idb,'A')
            tmod=1;
        end
        if (ida==66)&&(tmod==1)
            error(['Airfoil Series 66 do not have modified thickness',...
                  ' version! Use 66-XXX instead!'])
        end
    elseif numel(afid)==7
        idb=afid(4);
        if (~strcmpi(idb,'-'))&&(~strcmpi(idb,'A'))
            error(['Airfoil identifier must be a in 6X-XXX or',...
                  ' 6XAXXX format!'])
        end
        tmod=0;
    end
%Checking input dotcount
    if numel(dotcount)~=1
        error('Number of vertex must be scalar!')
    end
    if (mod(dotcount,1~=0))||(dotcount<0)
        error('Number of vertex must be positive integer!')
    end
%Checking input xmod
    if nargin<3
        xmod='Cosine';
    end
    if (~strcmpi(xmod,'Uniform'))&&(~strcmpi(xmod,'Cosine'))
        error('Vertex distribution input must be Uniform or Cosine!')
    end
%Declaring lookup table
    %Declaring look up table for camber line
    xctable=[0,1.25,2.5,5,7.5,10,15,20,25,30,40,50,60,70,80,90,95,100]/100;
    %yc62table=[0.000,0.726,1.406,2.625,3.656,4.500,5.625,6.000,5.977,...
    %           5.906,5.625,5.156,4.500,3.565,2.625,1.406,0.727,0.000]*...
    %          (1/0.90)/100;
    yc63table=[0.000,0.489,0.958,1.833,2.625,3.333,4.500,5.333,5.833,...
               6.000,5.878,5.510,4.898,4.041,2.939,1.592,0.827,0.000]*...
              (1/0.80)/100;
    yc64table=[0.000,0.369,0.726,1.406,2.039,2.625,3.656,4.500,5.156,...
               5.625,6.000,5.833,5.333,4.500,3.333,1.833,0.958,0.000]*...
              (1/0.76)/100;
    yc65table=[0.000,0.296,0.585,1.140,1.665,2.160,3.060,3.840,4.500,...
               5.040,5.760,6.000,5.760,5.040,3.840,2.160,1.140,0.000]*...
              (1/0.75)/100;
    yc66table=[0.000,0.247,0.490,0.958,1.406,1.833,2.625,3.333,3.958,...
               4.500,5.333,5.833,6.000,5.625,4.500,2.625,1.406,0.000]*...
              (1/0.76)/100;
    %yc67table=[0.000,0.212,0.421,0.827,1.217,1.592,2.296,2.939,3.520,...
    %           4.041,4.898,5.510,5.878,6.000,5.333,3.333,1.833,0.000]*...
    %          (1/0.80)/100;
    %Declaring look up table for thickness distribution
    xtable=[0,0.5,0.75,1.25,2.5,5,7.5,10,15,20,25,30,35,40,45,50,...
            55,60,65,70,75,80,85,90,95,100]/100;
    ttable=ones(1,26)/100;
    if tmod==0
        %Declaring table for Series 63
        x63table=[xtable;xtable;xtable;xtable;xtable;xtable;xtable;...
                  xtable;xtable];
        tmax63table=[0*ttable;6*ttable;9*ttable;10*ttable;12*ttable;...
                     15*ttable;18*ttable;21*ttable;99*ttable];
        t63table=[0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,...
                  0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,...
                  0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000;%0.00t
                  0.000,0.503,0.609,0.771,1.057,1.462,1.766,2.010,2.386,...
                  2.656,2.841,2.954,3.000,2.971,2.877,2.723,2.513,2.267,...
                  1.982,1.670,1.342,1.008,0.683,0.383,0.138,0.000;%0.06t
                  0.000,0.749,0.906,1.151,1.582,2.196,2.655,3.024,3.591,...
                  3.997,4.275,4.442,4.500,4.447,4.296,4.056,3.739,3.358,...
                  2.928,2.458,1.966,1.471,0.990,0.550,0.196,0.000;%0.09t
                  0.000,0.829,1.004,1.275,1.756,2.440,2.950,3.362,3.994,...
                  4.445,4.753,4.938,5.000,4.938,4.766,4.496,4.140,3.715,...
                  3.234,2.712,2.166,1.618,1.088,0.604,0.214,0.000;%0.10t
                  0.000,0.985,1.194,1.519,2.102,2.925,3.542,4.039,4.799,...
                  5.342,5.712,5.930,6.000,5.920,5.704,5.370,4.935,4.420,...
                  3.840,3.210,2.556,1.902,1.274,0.707,0.250,0.000;%0.12t
                  0.000,1.204,1.462,1.878,2.610,3.648,4.427,5.055,6.011,...
                  6.693,7.155,7.421,7.500,7.386,7.099,6.665,6.108,5.453,...
                  4.721,3.934,3.119,2.310,1.541,0.852,0.300,0.000;%0.15t
                  0.000,1.404,1.713,2.217,3.104,4.362,5.308,6.068,7.225,...
                  8.048,8.600,8.913,9.000,8.845,8.482,7.942,7.256,6.455,...
                  5.567,4.622,3.650,2.691,1.787,0.985,0.348,0.000;%0.18t
                  0.000,1.583,1.937,2.527,3.577,5.065,6.182,7.080,8.441,...
                  9.410,10.053,10.412,10.500,10.298,9.854,9.206,8.390,...
                  7.441,6.396,5.290,4.160,3.054,2.021,1.113,0.392,...
                  0.000]/100;%0.21t
        t63table=[t63table;t63table(end,:)*(99/21)];
        %Declaring table for Series 64
        x64table=[xtable;xtable;xtable;xtable;xtable;xtable;xtable;...
                  xtable;xtable;xtable];
        tmax64table=[0*ttable;6*ttable;8*ttable;9*ttable;10*ttable;...
                     12*ttable;15*ttable;18*ttable;21*ttable;99*ttable];
        t64table=[0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,...
                  0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,...
                  0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000;%0.00t
                  0.000,0.494,0.596,0.754,1.024,1.405,1.692,1.928,2.298,...
                  2.572,2.772,2.907,2.981,2.995,2.919,2.775,2.575,2.331,...
                  2.050,1.740,1.412,1.072,0.737,0.423,0.153,0.000;%0.06t
                  0.000,0.658,0.794,1.005,1.365,1.875,2.259,2.574,3.069,...
                  3.437,3.704,3.884,3.979,3.992,3.883,3.684,3.411,3.081,...
                  2.704,2.291,1.854,1.404,0.961,0.550,0.206,0.000;%0.08t
                  0.000,0.739,0.892,1.128,1.533,2.109,2.543,2.898,3.455,...
                  3.868,4.170,4.373,4.479,4.490,4.364,4.136,3.826,3.452,...
                  3.026,2.561,2.069,1.564,1.069,0.611,0.227,0.000;%0.09t
                  0.000,0.820,0.989,0.125,1.701,2.343,2.826,3.221,3.842,...
                  4.302,4.639,4.864,4.980,4.988,4.843,4.586,4.238,3.820,...
                  3.345,2.827,2.281,1.722,1.176,0.671,0.248,0.000;%0.10t
                  0.000,0.978,1.179,1.490,2.035,2.810,3.394,3.871,4.620,...
                  5.173,5.576,5.844,5.978,5.981,5.798,5.480,5.056,4.548,...
                  3.974,3.350,2.695,2.029,1.382,0.786,0.288,0.000;%0.12t
                  0.000,1.208,1.456,1.842,2.528,3.504,4.240,4.842,5.785,...
                  6.480,6.985,7.319,7.482,7.473,7.224,6.810,6.266,5.620,...
                  4.895,4.113,3.296,2.472,1.677,0.950,0.346,0.000;%0.15t
                  0.000,1.428,1.720,2.177,3.005,4.186,5.076,5.803,6.942,...
                  7.782,8.391,8.789,8.979,8.952,8.630,8.114,7.445,6.658,...
                  5.782,4.842,3.866,2.888,1.951,1.101,0.400,0.000;%0.18t
                  0.000,1.646,1.985,2.517,3.485,4.871,5.915,6.769,8.108,...
                  9.095,9.807,10.259,10.481,10.431,10.030,9.404,8.607,...
                  7.678,6.649,5.549,4.416,3.287,2.213,1.245,0.449,...
                  0.000]/100;%0.21t
        t64table=[t64table;t64table(end,:)*(99/21)];
        %Declaring table for Series 65
        x65table=[xtable;xtable;xtable;xtable;xtable;xtable;xtable;...
                  xtable;xtable;xtable];
        tmax65table=[0*ttable;6*ttable;8*ttable;9*ttable;10*ttable;...
                     12*ttable;15*ttable;18*ttable;21*ttable;99*ttable];
        t65table=[0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,...
                  0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,...
                  0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000;%0.00t
                  0.000,0.476,0.574,0.717,0.956,1.310,1.589,1.824,2.197,...
                  2.482,2.697,2.852,2.952,2.998,2.983,2.900,2.741,2.518,...
                  2.246,1.935,1.594,1.233,0.865,0.510,0.195,0.000;%0.06t
                  0.000,0.627,0.756,0.945,1.267,1.745,2.118,2.432,2.931,...
                  3.312,3.599,3.805,3.938,3.998,3.974,3.857,3.638,3.337,...
                  2.971,2.553,2.096,1.617,1.131,0.664,0.252,0.000;%0.08t
                  0.000,0.700,0.845,1.058,1.421,1.961,2.383,2.736,3.299,...
                  3.727,4.050,4.282,4.431,4.496,4.469,4.336,4.086,3.743,...
                  3.328,2.856,2.342,1.805,1.260,0.738,0.280,0.000;%0.09t
                  0.000,0.772,0.932,1.169,1.574,2.177,2.647,3.040,3.666,...
                  4.143,4.503,4.760,4.924,4.996,4.963,4.812,4.530,4.146,...
                  3.682,3.156,2.584,1.987,1.385,0.810,0.306,0.000;%0.10t
                  0.000,0.923,1.109,1.387,1.875,2.606,3.172,3.647,4.402,...
                  4.975,5.406,5.716,5.912,5.997,5.949,5.757,5.412,4.943,...
                  4.381,3.743,3.059,2.345,1.630,0.947,0.356,0.000;%0.12t
                  0.000,1.124,1.356,1.702,2.324,3.245,3.959,4.555,5.504,...
                  6.223,6.764,7.152,7.396,7.498,7.427,7.168,6.720,6.118,...
                  5.403,4.600,3.744,2.858,1.977,1.144,0.428,0.000;%0.15t
                  0.000,1.337,1.608,2.014,2.751,3.866,4.733,5.457,6.606,...
                  7.476,8.129,8.595,8.886,8.999,8.901,8.508,8.008,7.267,...
                  6.395,5.426,4.396,3.338,2.295,1.319,0.490,0.000;%0.18t
                  0.000,1.522,1.838,2.301,3.154,4.472,5.498,6.352,7.700,...
                  8.720,9.487,10.036,10.375,10.499,10.366,9.952,9.277,...
                  8.390,7.360,6.224,5.024,3.800,2.598,1.484,0.546,...
                  0.000]/100;%0.21t
        t65table=[t65table;t65table(end,:)*(99/21)];
        %Declaring table for Series 66
        x66table=[xtable;xtable;xtable;xtable;xtable;xtable;xtable;...
                  xtable;xtable;xtable];
        tmax66table=[0*ttable;6*ttable;8*ttable;9*ttable;10*ttable;...
                     12*ttable;15*ttable;18*ttable;21*ttable;99*ttable];
        t66table=[0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,...
                  0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,...
                  0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000;%0.00t
                  0.000,0.461,0.554,0.693,0.918,1.257,1.524,1.752,2.199,...
                  2.401,2.618,2.782,2.899,2.971,3.000,2.985,2.925,2.815,...
                  2.611,2.316,1.953,1.543,1.107,0.665,0.262,0.000%0.06t
                  0.000,0.610,0.735,0.919,1.219,1.673,2.031,2.335,2.826,...
                  3.201,3.490,3.709,3.865,3.962,4.000,3.978,3.896,3.740,...
                  3.459,3.062,2.574,2.027,1.447,0.864,0.338,0.000;%0.08t
                  0.000,0.687,0.824,1.030,1.368,1.880,2.283,2.626,3.178,...
                  3.601,3.927,4.173,4.348,4.457,4.499,4.475,4.381,4.204,...
                  3.882,3.428,2.877,2.263,1.611,0.961,0.374,0.000;%0.09t
                  0.000,0.759,0.913,1.141,1.516,2.087,2.536,2.917,3.530,...
                  4.001,4.363,4.636,4.832,4.953,5.000,4.971,4.865,4.665,...
                  4.302,3.787,3.176,2.494,1.773,1.054,0.408,0.000;%0.10t
                  0.000,0.906,1.087,1.358,1.808,2.496,3.037,3.496,4.234,...
                  4.801,5.238,5.568,5.803,5.947,6.000,5.965,5.836,5.588,...
                  5.139,4.515,3.767,2.944,2.083,1.234,0.474,0.000;%0.12t
                  0.000,1.122,1.343,1.675,2.235,3.100,3.781,4.358,5.286,...
                  5.995,6.543,6.956,7.250,7.430,7.495,7.450,7.283,6.959,...
                  6.372,5.576,4.632,3.598,2.530,1.489,0.566,0.000;%0.15t
                  0.000,1.323,1.571,1.952,2.646,3.690,4.513,5.210,6.333,...
                  7.188,7.848,8.346,8.701,8.918,8.998,8.942,8.733,8.323,...
                  7.580,6.597,5.451,4.206,2.934,1.714,0.646,0.000;%0.18t
                  0.000,1.525,1.804,2.240,3.045,4.269,5.233,6.052,7.369,...
                  8.376,9.153,9.738,10.154,10.407,10.500,10.434,10.186,...
                  9.692,8.793,7.610,6.251,4.796,3.324,1.924,0.717,...
                  0.000]/100;%0.21t
        t66table=[t66table;t66table(end,:)*(99/21)];
    elseif tmod==1
        %Declaring table for Series 63A
        x63table=[xtable;xtable;xtable;xtable;xtable;xtable;xtable];
        tmax63table=[0*ttable;6*ttable;8*ttable;10*ttable;12*ttable;...
                     15*ttable;99*ttable];
        t63table=[0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,...
                  0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,...
                  0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000;%0.00t
                  0.000,0.495,0.595,0.754,1.045,1.447,1.747,1.989,2.362,...
                  2.631,2.820,2.942,2.996,2.985,2.914,2.788,2.613,2.396,...
                  2.143,1.859,1.556,1.248,0.939,0.630,0.322,0.013;%0.06t
                  0.000,0.658,0.791,1.003,1.391,1.930,2.332,2.656,3.155,...
                  3.515,3.766,3.926,3.995,3.978,3.878,3.705,3.468,3.176,...
                  2.837,2.457,2.055,1.647,1.240,0.833,0.425,0.018;%0.08t
                  0.000,0.816,0.983,1.250,1.737,2.412,2.917,3.324,3.950,...
                  4.400,4.714,4.913,4.995,4.968,4.837,4.613,4.311,3.943,...
                  3.517,3.044,2.545,2.040,1.535,1.030,0.525,0.021;%0.10t
                  0.000,0.973,1.173,1.492,2.078,2.895,3.504,3.994,4.747,...
                  5.287,5.664,5.901,5.995,5.957,5.792,5.517,5.148,4.700,...
                  4.186,3.621,3.026,2.426,1.826,1.225,0.625,0.025;%0.12t
                  0.000,1.203,1.448,1.844,2.579,3.618,4.382,4.997,5.942,...
                  6.619,7.091,7.384,7.496,7.435,7.215,6.858,6.387,5.820,...
                  5.173,4.468,3.731,2.991,2.252,1.512,0.772,...
                  0.032]/100;%0.15t
        t63table=[t63table;t63table(end,:)*(99/15)];
        %Declaring table for Series 64A
        x64table=[xtable;xtable;xtable;xtable;xtable;xtable;xtable];
        tmax64table=[0*ttable;6*ttable;8*ttable;10*ttable;12*ttable;...
                     15*ttable;99*ttable];
        t64table=[0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,...
                  0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,...
                  0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000;%0.00t
                  0.000,0.485,0.585,0.739,1.016,1.399,1.684,1.919,2.283,...
                  2.557,2.757,2.896,2.977,2.999,2.945,2.825,2.653,2.438,...
                  2.188,1.907,1.602,1.285,0.967,0.649,0.331,0.013;%0.06t
                  0.000,0.646,0.778,0.983,1.353,1.863,2.245,2.559,3.047,...
                  3.414,3.681,3.866,3.972,3.998,3.921,3.757,3.524,3.234,...
                  2.897,2.521,2.117,1.698,1.278,0.858,0.438,0.018;%0.08t
                  0.000,0.804,0.969,1.225,1.688,2.327,2.905,3.199,3.813,...
                  4.272,4.606,4.837,4.968,4.995,4.894,4.684,4.388,4.021,...
                  3.597,3.127,2.623,2.103,1.582,1.062,0.541,0.021;%0.10t
                  0.000,0.961,1.158,1.464,2.018,2.788,3.364,3.839,4.580,...
                  5.132,5.534,5.809,5.965,5.993,5.863,5.605,5.244,4.801,...
                  4.289,3.721,3.118,2.500,1.882,1.263,0.644,0.025;%0.12t
                  0.000,1.193,1.436,1.815,2.508,3.477,4.202,4.799,5.732,...
                  6.423,6.926,7.270,7.463,7.487,7.313,6.978,6.517,5.956,...
                  5.311,4.600,3.847,3.084,2.321,1.558,0.795,...
                  0.032]/100;%0.15t
        t64table=[t64table;t64table(end,:)*(99/15)];
        %Declaring table for Series 65A
        x65table=[xtable;xtable;xtable;xtable;xtable;xtable;xtable];
        tmax65table=[0*ttable;6*ttable;8*ttable;10*ttable;12*ttable;...
                     15*ttable;99*ttable];
        t65table=[0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,...
            0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,...
            0.000,0.000,0.000,0.000,0.000,0.000,0.000;%0.00t
                  0.000,0.464,0.563,0.718,0.981,1.313,1.591,1.824,2.194,...
                  2.474,2.687,2.842,2.945,2.996,2.992,2.925,2.793,2.602,...
                  2.364,2.087,1.775,1.437,1.083,0.727,0.370,0.013;%0.06t
                  0.000,0.615,0.746,0.951,1.303,1.749,2.120,2.432,2.926,...
                  3.301,3.585,3.791,3.928,3.995,3.988,3.895,3.714,3.456,...
                  3.135,2.763,2.348,1.898,1.430,0.960,0.489,0.018;%0.08t
                  0.000,0.765,0.928,1.183,1.623,2.182,2.650,3.040,3.658,...
                  4.127,4.483,4.742,4.912,4.995,4.983,4.863,4.632,4.304,...
                  3.899,3.432,2.912,2.352,1.771,1.188,0.604,0.021;%0.10t
                  0.000,0.913,1.106,1.414,1.942,2.614,3.176,3.647,4.392,...
                  4.956,5.383,3.693,5.897,5.995,5.977,5.828,5.544,5.143,...
                  4.654,4.091,3.467,2.798,2.106,1.413,0.719,0.025;%0.12t
                  0.000,1.131,1.371,1.750,2.412,3.255,3.962,4.553,5.488,...
                  6.198,6.734,7.122,7.376,7.496,7.467,7.269,6.903,6.393,...
                  5.772,5.063,4.282,3.451,2.598,1.743,0.887,...
                  0.032]/100;%0.15t
        t65table=[t65table;t65table(end,:)*(99/15)];
    end
%Assigning identifier to equation coefficient
    id1=str2double(afid(2));
    if numel(afid)==6
        id2=str2double(afid(4));
        id3=str2double(afid([5,6]));
    elseif numel(afid)==7
        id2=str2double(afid(5));
        id3=str2double(afid([6,7]));
    end
    xminp=id1*(10/100);         %Minimum pressure location
    cl=id2*(10/100);            %Design lift coefficient
    t=id3*(1/100);              %Maximum thickness
    if t==0
        warning(['Zero thickness airfoil!',...
                ' Airfoil will be just a camber line!'])
    end
%Calculating x-axis location of camber line vertexes
    panelcount=dotcount-1;
    if strcmpi(xmod,'Uniform')
        panellength=1/panelcount;
        xc=(0:panellength:1)';
    elseif strcmpi(xmod,'Cosine')
        deltadeg=90/panelcount;
        xc=1-cosd(0:deltadeg:90)';
    end
%Preallocating array for speed
    yc=zeros(dotcount,1);
    gc=zeros(dotcount,1);
    yt=zeros(dotcount,1);
    xu=zeros(dotcount,1);
    xl=zeros(dotcount,1);
    yu=zeros(dotcount,1);
    yl=zeros(dotcount,1);
%Calculating y-axis location of camber line vertexes and camber gradient
    if ida==63
        for i=2:1:dotcount-1
            yc(i)=interp1(xctable,yc63table,xc(i))*cl;
        end
    elseif ida==64
        for i=2:1:dotcount-1
            yc(i)=interp1(xctable,yc64table,xc(i))*cl;
        end
    elseif ida==65
        for i=2:1:dotcount-1
            yc(i)=interp1(xctable,yc65table,xc(i))*cl;
        end
    elseif ida==66
         for i=2:1:dotcount-1
            yc(i)=interp1(xctable,yc66table,xc(i))*cl;
        end
    end
    for i=2:1:dotcount-1
        gc(i)=(yc(i+1)-yc(i-1))/(xc(i+1)-xc(i-1));
    end
%Converting camber gradient to camber slope and normal
    sc=atand(gc);
%Calculating thickness distribution
    if ida==63
        for i=1:1:dotcount
            yt(i)=interp2(x63table,tmax63table,t63table,xc(i),t);
        end
    elseif ida==64
        for i=1:1:dotcount
            yt(i)=interp2(x64table,tmax64table,t64table,xc(i),t);
        end
    elseif ida==65
        for i=1:1:dotcount
            yt(i)=interp2(x65table,tmax65table,t65table,xc(i),t);
        end
    elseif ida==66
        for i=1:1:dotcount
            yt(i)=interp2(x66table,tmax66table,t66table,xc(i),t);
        end
    end
%Generating airfoil vertexes
    for i=1:1:dotcount
        xu(i)=xc(i)-yt(i)*sind(sc(i));
        yu(i)=yc(i)+yt(i)*cosd(sc(i));
        xl(i)=xc(i)+yt(i)*sind(sc(i));
        yl(i)=yc(i)-yt(i)*cosd(sc(i));
    end
%CodeEnd-------------------------------------------------------------------

end